package com.app.housemanage.domain.vo;

import java.util.List;

/**
 * 响应工具类
 */
public class ResponseUtils {
    
    /**
     * 成功响应
     */
    public static <T> ApiResult<T> success() {
        return ApiResult.success(null);
    }
    
    public static <T> ApiResult<T> success(T data) {
        return ApiResult.success(data);
    }
    
    public static <T> ApiResult<T> success(String message, T data) {
        return ApiResult.success(message, data);
    }
    
    /**
     * 创建成功响应
     */
    public static <T> ApiResult<T> created(T data) {
        return ApiResult.created(data);
    }
    
    /**
     * 分页成功响应
     */
    public static <T> ApiResult<PageResult<T>> pageSuccess(com.baomidou.mybatisplus.extension.plugins.pagination.Page<T> page) {
        PageResult<T> pageResult = PageResult.of(page);
        return ApiResult.success(pageResult);
    }
    
    public static <T> ApiResult<PageResult<T>> pageSuccess(Integer pageNum, Integer pageSize, Long total, List<T> list) {
        PageResult<T> pageResult = new PageResult<>(pageNum, pageSize, total, list);
        return ApiResult.success(pageResult);
    }
    
    /**
     * 错误响应
     */
    public static <T> ApiResult<T> error(String message) {
        return ApiResult.error(message);
    }
    
    public static <T> ApiResult<T> error(Integer code, String message) {
        return ApiResult.error(code, message);
    }
    
    /**
     * 客户端错误响应
     */
    public static <T> ApiResult<T> badRequest(String message) {
        return ApiResult.badRequest(message);
    }
    
    public static <T> ApiResult<T> unauthorized(String message) {
        return ApiResult.unauthorized(message);
    }
    
    public static <T> ApiResult<T> forbidden(String message) {
        return ApiResult.forbidden(message);
    }
    
    public static <T> ApiResult<T> notFound() {
        return ApiResult.notFound();
    }
    
    /**
     * 服务器错误响应
     */
    public static <T> ApiResult<T> internalServerError(String message) {
        return ApiResult.error(ApiResult.INTERNAL_SERVER_ERROR_CODE, message);
    }
    
    public static <T> ApiResult<T> serviceUnavailable(String message) {
        return ApiResult.serviceUnavailable(message);
    }
}